//-----------------------------------------------------------------------------
// Bend2D - Physics Engine
// Roberto Bender <beto.bender@gmail.com>
// Description: 
// Date: 16/03/2010
//-----------------------------------------------------------------------------
#include "physicable.h"
using namespace bend2d;

Physicable::Physicable() :
    m_Mass(1.0),
    m_Elastic(0),
    m_Friction(0)
{
}

Physicable::Physicable(double mass, double elastic, double friction) :
    m_Mass(mass),
    m_Elastic(elastic),
    m_Friction(friction)
{
}

void Physicable::SetMass(double mass)
{
    m_Mass = mass;
}

void Physicable::SetElastic(double elastic)
{
    m_Elastic = elastic;
}

void Physicable::SetFriction(double friction)
{
    m_Friction = friction;
}

double Physicable::GetMass() const
{
    return m_Mass;
}

double Physicable::GetElastic() const
{
    return m_Elastic;
}

double Physicable::GetFriction() const
{
    return m_Friction;
}

void Physicable::ResetForces()
{
    m_ResultForce = Acceleration(0,0);
}

void Physicable::ApplyForce(const Acceleration& acceleration)
{
    Acceleration cpy = acceleration;
    cpy.SetMag(cpy.GetMag() - m_Friction);
    m_ResultForce += cpy;
}

const Acceleration& Physicable::GetResultForces() const
{
    return m_ResultForce;
}

Physicable::PhysicableList::iterator& Physicable::GetPhysicableIterator() 
{
    return m_Iterator;
}
